﻿using MediatR;
using MES.Bom.API.Application.Command.BOM命令;
using MES.Bom.API.Application.Command.成品命令;
using MES.Bom.API.Application.Command.物料命令;
using MES.Bom.Domain;
using MES.Bom.Dto;
using MES.Bom.ErrorCode;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace MES.Bom.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BomManageController : ControllerBase
    {
        private readonly IMediator mediator;

        public BomManageController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 获取成品列表 
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<APIPaging<Goods>>> GoodsQuery([FromQuery]GoodsQueryCommand request) 
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// BOM添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> BomAdd(BomAddCommand request) 
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 物料选择列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<APIPaging<Material>>> MaterailQuery([FromQuery]MaterailQueryCommand request) 
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 物料分配工序（单个）
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> MaterailProcess(MaterailProcessAddCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 获取BOM列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<APIPaging<BomGoodsDto>>> BomQuery([FromQuery]BomQueryCommand request)
        {
            return mediator.Send(request);
        }
    }
}
